package com.ease.job.quartz.support;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

import com.ease.job.quartz.service.CronJobExecutionService;

public class CronJobManagerServletContextListener implements ServletContextListener {

	private CronJobExecutionService cronJobExecutionService;

	public void contextInitialized(ServletContextEvent event) {
		// TODO
	}

	public void contextDestroyed(ServletContextEvent event) {
		event.getServletContext().log("begin to stop all jobs--");
		cronJobExecutionService.shutdownAll();
		event.getServletContext().log("end to stop all jobs--");
	}

	/**
	 * @return the cronJobExecutionService
	 */
	public CronJobExecutionService getCronJobExecutionService() {
		return cronJobExecutionService;
	}

	/**
	 * @param cronJobExecutionService
	 *            the cronJobExecutionService to set
	 */
	public void setCronJobExecutionService(CronJobExecutionService cronJobExecutionService) {
		this.cronJobExecutionService = cronJobExecutionService;
	}

}
